#!/usr/bin/env python

import ConfigParser,mylog,deployNopass,sys,cloud

logger=mylog.initlog('init deploy',1)

username = sys.argv[1]
password = sys.argv[2]

logger.debug(username)
logger.debug(password)

master, slave1 = deployNopass.createVm(logger)

deployNopass.startVm(master, slave1, logger)

deployNopass.nfsConf(master, slave1, logger)
deployNopass.nfsExport(master, logger)
deployNopass.mountSlave(slave1, master, logger)
deployNopass.fstabConf(slave1, master, logger)
deployNopass.createUser(master, username, password, logger)
deployNopass.loadBalanceConf(master, slave1, logger)
deployNopass.loadBalanceStart(master, logger)
deployNopass.phpmyadminConf(master, logger)
deployNopass.mysqlAddUser(master, username, password, 1, logger)

message = "User Name: %s\n\
 Password: %s\n\
  Web URL: http://%s\n\
      FTP: %s\n\
    MySQL: http://%s/craneutility/phpmyadmin" % (username, password, master, master, master)

print message

f = open('../userInfo/'+username, 'w')
f.write(message)
f.close()
